package UpFile

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"strconv"
	"time"
)

func UpFileIndex(context *gin.Context) {
	context.HTML(200, "demo01/index.html", nil)
}
func UpSumFile(context *gin.Context) {
	//获取form
	form, _ := context.MultipartForm()

	//获取上传的文件
	files := form.File["myfile"]
	//生成时间戳并转换为字符串
	time_int := time.Now().Unix()
	time_string := strconv.FormatInt(time_int, 10)

	//循环调用文件保存方法
	for _, file := range files {
		fmt.Println(file)
		context.SaveUploadedFile(file, "D://"+time_string+file.Filename)
	}
	//返回上传成功
	context.JSON(200, gin.H{
		"msg": "上传成功",
	})
}
